
# 无重复的最长字


class Solution:
    def __init__(self):
        pass

    def run(self,s):
        res = (0,float('-inf'))
        i= 0
        hs = {}
        for j,e in  enumerate(s):
            if e in hs.keys()  :  #1 表示遇到重复元素  求取前面的字符串的长度比较
                i = j
            if j-i > res[1] - res[0]:  # 大于的时候才更新，否则没必要
                        res = (i,j)       #不断更新res
            hs[e] = j
        return res[1]-res[0]+1,res


if __name__ == '__main__':
    s = Solution()
    print(s.run('pwwkewcdcd456789'))




